home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
HENSA
/
GRAPHICS
/
FRACTAL.ARC
/
!PalGen
/
!Help
< prev
next >
Wrap
Text File
|
1994-12-12
|
9KB
|
195 lines
Documentation for !PalGen
By Ian Nichols
Like many freeware programs, !PalGen was written partly as a programming
exercise and partly to do something the way that the programmer wants it to
be done rather than the way everyone else seems to do it. In this case, the
task in question is the generation and editing of 256 colour palettes,
primarily for use with images created by !Fractal, but the palettes can also
be used with any RISC OS 256-colour sprite. Though it was developed on an
ageing A310 with no more graphics enhancement than a VIDC enhancer, it is
intended to be used on a machine with VIDC20, which allows the 256 colours to
be selected from a 24-bit palette. It has been tried on a RiscPC (someone
else's - I'm still saving!) and seems to work as expected.
!PalGen can also save and load 256 colour palettes in the form used by the PC
freeware program FractInt.
The way in which !PalGen works is somewhat different from other palette
editors you may have seen. Instead of setting colours individually or
setting groups of colours by interpolating between two endpoints, !PalGen
represents the whole palette as a set of 3 histograms; one for the red
intensities, one for the green and one for the blue. These histograms can be
altered using the mouse or by means of 3 equations.
!PalGen has been written to be fully RISC OS compliant, and considering that
it is only my second Wimp program I am quite pleased with its behaviour. It
supports both the file and RAM transfer protocols, although you do get some
strange error messages when saving palettes into sprites in !Paint. I am told
that this is almost certainly due to a bug in !Paint, but if there is someone
out there who can find a bug in !PalGen which is causing this, please could
they tell me!.
Using !PalGen
-------------
Starting the application and opening the main window are all done in the
usual RISC OS way. I have not set up a run action for palette files (type
&FED), so to load them you will have to drag their icons onto the !PalGen
icon bar icon or the main window if it is open. The default 256 colour
palette is automatically loaded when the program starts (this is the same on a RiscPC as on the older machines).
Clicking on the icon bar icon, or dragging a palette file onto it will open
the main window and the palette window. By default the main window will
display the histogram for red intensities. You can view and edit the green
or blue intensities by clicking on the appropriate radio button. Please be
patient, it is interpreted BASIC after all. Each column of the histogram
represents the intensity (0-255) of a logical colour (also 0-255). As you
move the mouse pointer over the histogram, the logical colour number and
intensity corresponding to the mouse pointer position are displayed to the
right of the radio buttons.
Clicking with...
Select: Will set the intensity of the red, green or blue component of the
logical colour corresponding to the pointer position.
Adjust: Will set the intensity of the red, green or blue component of the
logical colour correspoding to the pointer position and interpolate
all the colours between the current pointer position and the last
pointer position where a mouse click took place.
Note that if you hold down the mouse button, both of these actions will
auto-repeat as fast as the program can keep up. The palette display (if
open) will update immediately.
Clicking with Menu whilst over the main window will open a menu with the
following items:
Save Opens a save box
Equations Opens the 'Alter with equations' dialogue box.
Show Palette Opens the palette display if it is closed.
The Save box is not quite the standard RISC OS item - it has two radio
buttons to select the type of file you wish to save the palette as (see later
for brief description of the two types. The palette is saved in the usual
RISC OS way, i.e. you drag the file icon to a filer window (or the
appropriate window of whatever other application you want to save it into).
The 'Alter with equations' dialogue box contains 3 writable icons into which
you can type equations to alter the red, green and blue components of the
colours in the palette. If you press RETURN or click on the 'Alter Palette'
icon, the program will execute a FOR...NEXT loop for each logical colour
(0-255), applying the expressions to the appropriate colour component.
There are 2 variables which you can use in the expressions you type: LCN% and
CV%. LCN% is simply the logical colour number. CV% is used to store the
current value of each colour component for each logical colour just before
the expression is evaluated, i.e. leaving the expression as 'CV%' (the
default) will not change that component of the palette. CV%/2 will divide
the intensities of a colour component by 2 for the whole palette.
Intensities greater than 255 or less than 0 are checked for and clipped if
necessary.
File Types Supported
--------------------
Two file types are supported: the standard RISC OS 256 colour palette, as
exported by !Paint and as used by !Fractal, and the 256 colour palette files
used by the PC freeware program FractInt.
The RISC OS palette files contain a sequence of 6 bytes for each colour as
follows:
19 <logical colour number> 16 <Red> <green> <blue>
This sequence corresponds to the BASIC command
VDU 19,l,p,r,g,b
Which is used to set the physical colour of logical colour 'l'. These files
are identified by having the file type &FED and being 1536 bytes long. When
files of type &FED are loaded into !PalGen, the length of the file is checked
and the first 3 bytes are tested (they will always be 19 0 16 if all is
well).
The files used by FractInt are plain ASCII text files and should be given the
type &FFF (text) before you try to import them. When you export this type of
file, remember to give them the extension .MAP before you try to load them
into FractInt. They consist of red, green and blue values (separated by
spaces) for each logical colour in order, starting with 0, one line for each
logical colour. They may also contain embedded comments on any line, after
the colour information.
Because they are constructed in this way, these files do not have a fixed
length, which makes them slightly trickier to deal with. If you have
problems importing these, load them into your favourite text editor and
examine them, bearing in mind the following points.
1) !PalGen checks that the first 3 bytes of the file give a valid
number in the range 0-255. It does this by reading successive
bytes from the file until it finds a numeric character, then
assembles successive bytes into a string until it encounters a
non-numeric character. If it has read more than four bytes
(i.e. 3 digits plus the next, non-numeric, character) then it
assumes that the file is not a valid palette file and reports
an error.
2) If the file contains any comments then they should be separated
from the colour information by at least one TAB character
(ASCII 9). Note that any comments are ignored when !PalGen
imports these files and that !PalGen adds comments of its own
when exporting palettes in this format.
Well, I hope someone out there finds this program useful. If anyone is
wondering why I have included some sort of support for a PC program, the
answer is this: I believe that if Acorn machines and RISC OS are to survive
as a computing platform, it is important that we can exchange data with
users of other platforms in both directions. Especially when those 'users of
other platforms' are also ourselves. Acorn users can import a variety of data
types from other platforms (mostly the IBM PC clones), but this is almost an
implicit admission that our platform is 'not good enough' - if it's any good,
why can't we create our own masterpieces? Well we can, its just that we can't
easily get them onto other types of computer....
I like to think that in some small way I am helping to spread the message of data portability by doing this.
!PalGen is freeware. You can give it to whoever you like as long as you
include this file don't charge them any money (except for the disc). The
author retains copyright of !PalGen.
Finally, thanks to...
Mike Curnow et al for producing !Fractal, which led me to want to write this
program in the first place, thereby forcing me to tackle the intricacies of
RISC OS compliance.
The Stone Soup group for producing FractInt, (even though they did have to do
it on a PC clone) which, I believe, inspired !Fractal.
Whoever it was who designed the icon for filetype &FED (palette) which I have
included with this program (it is loaded by the IconSprites command in the
!Boot file). Likewise the nice round radio buttons.
Dominic Symes for producing !Zap - the best text editor at the price (ha ha).
Ian Nichols
128 Westbury Road
Westbury-on-Trym
Bristol
BS9 3AR